states_needed = set(["mt", "wa", "or", "id", "nv", "ut", "ca","az"])  # 需要覆盖的区域

stations = {}  # 广播
stations["kone"] = set({"id", "nv", "ut"})
stations["ktwo"] = set({"wa", "id", "mt"})
stations["kthree"] = set({"or", "nv", "ca"})
stations["kfour"] = set({"nv", "ut"})
stations["kfive"] = set({"ca", "az"})

final_stations = set()

while states_needed:  # 只要未覆盖全，则一直循环
    best_station = None
    states_covered = set()
    for station, states_for_station in stations.items():
        covered = states_needed & states_for_station
        if len(covered) > len(states_covered):  # 循环找出覆盖了最多未覆盖区域的广播
            best_station = station
            states_covered = covered

    final_stations.add(best_station)  # 保存选择的广播列表中

    states_needed -= states_covered  # 删除已经被覆盖的区域

print(final_stations)
